import React, {PureComponent,Component} from 'react'
import {Button} from "antd";

class Child extends PureComponent{
render(){
    console.log('不依赖父组件状态，父组件状态更新了，我重新渲染了么')
    return(
        <div>xxxx</div>
    )
}
}

export default class MyPureComponent extends Component {
    state={count:1}
    addCount=()=>{
        this.setState({count:this.state.count+1})
    }
    render() {
        return (
            <div>
                <h2>使用PureComponent实现局部更新,子组件必须继承PureComponent</h2>
                <span>count:{this.state.count}</span>
                <Button onClick={this.addCount}>加count</Button>
                <Child></Child>
            </div>
        )
    }
}
